adding more options for layout and cleaning up the code a bit