Observer function working correctly