Style and reduce redundant code