Code completely works for the first time