Finalised res search function