done but needs to be optimized