Reverting to old code from commit da10b7f4d5a3e524a19d38ce3e5ea9d4856d1fe4