consolidate/clean up code