Moved filtering function outside of query thanks to Lwt.map