cleans up nested code a bit