Reverted code and fixed bug at source