cleanup code a little