Improved code and added stub spec