An attempt to improve performance - reduce number of push/pop operations with stack, number of objects