cleaned up code more and simiplfied as much as possible