trying to simplify the code and make it less painfull to look at