cleanred up the code a little