Improved code, removed dependency