added source code from konsteirama to work with