Removed unneccessary code. Made sure to have the atomic variables ready earlier