First implementation of code