cleanded up the code