Added support for direct input and fixed formatting.