changed code to use this instead of scope