Fixed bug in fetch logic