changed syntax, improved performance and implementation