Background process in custom shell

Hi I am trying to make my own custom shell, and I am having an issue with the background processes. The command runs in the background but it waits for me to press enter before it shows the prompt again. I can't seem to find what the issue is.

I had another issue where it wasnt parsing the commands properly and & was being passed into the list of commands but I moved the backGroundExecution command after the if (args[0]) statement. the & doesnt get passed now. But the issue remains some commands it shows the prompt immediately if i do sleep 10 & or environ & it shows. But commands like ls & or dir &, date & it still waits for me to press enter.

nevermind, I use zsh and this handled by zsh. After trying bg process with bash it gives similar output to mine so I am happy with that.