Replaced vector operations with more scala-like