merging rauljim's code