implemented stackTrace
cleaned up code