fixes to lastComponent function