fixed bug in before name extraction func