Added support for min-width and cleaned up code