Added better use of stack (more dynamic for later use).