cleanup code a bit