edited and added code from IntelliJ 11.5