cleand up code a bit