Used vectors instead of lists to significantly improve performance